﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class GlobalFunction_FindPassWord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string UserName = string.Empty;
            UIMethod.GetQuery(ref UserName, "username", true);
            if (UserName.Trim() != string.Empty)
            {
                txt_UserName.Text = UserName;                               
                lbl_Question.Text = DataEntity.tab_Admin.GetQuestion(UserName);
            }
        }
    }

    protected void btn_submit_Click(object sender, EventArgs e)
    {
        string newrandom = UIMethod.RandomWord(6);        
        bool result = DataEntity.tab_Admin.CreateNewPass(txt_UserName.Text, txt_Answer.Text, UIMethod.GetMD5(newrandom));

        if (result)
        {
            UIMethod.Alert("已生成新密码!");
            lbl_NewPass.Text = newrandom;
        }
        else { UIMethod.Alert("回答不正确!"); }

        txt_Answer.Text = string.Empty;
    }

}
